from selenium import webdriver
import os
import requests
import sys
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.firefox.options import Options

options = Options()
options.headless = True

print("Loading...")

os.system("rm -rf geckodriver.log")
driver = webdriver.Firefox(options=options)

print("Write video link: without http/s")
vlink = input()

print("Please wait...")

driver.get("https://getvideo.org")
time.sleep(2.5)

searchbar = driver.find_element(By.XPATH, """//*[@id="url"]""")

searchbar.send_keys(vlink)
time.sleep(2.5)

button = driver.find_element(By.XPATH, """/html/body/div[2]/div[2]/form/button""")

button.click()
time.sleep(5)

download = driver.find_element(By.XPATH, """/html/body/div[2]/div[4]/div[1]/div[1]/div/div[1]/table/tbody/tr[2]/td[2]/a""")
downlink = download.get_attribute("href")
os.system(f"wget \"{downlink}\" -O video.mp4")
